#include <gtk/gtk.h>   //导入gtk

 static void click_c(GtkButton *btn,gpointer user_data){
  //控制台打印
    g_print("Clicked.\n");
 }

//
static void app_activate (GApplication *app, gpointer *user_data) {
  GtkWidget *win;

  //按钮
  GtkWidget *btn;

  win = gtk_application_window_new (GTK_APPLICATION (app));
  //设置标题
  gtk_window_set_title (GTK_WINDOW (win), "我的第一个c语言窗口");
  //设置默认大小
  gtk_window_set_default_size (GTK_WINDOW (win), 400, 300);

  //设置一个按钮
  btn = gtk_button_new_with_label("单击我");
  //添加按钮到窗体上
  gtk_window_set_child(GTK_WINDOW(win),btn);
  //单击处理：进行回调
  g_signal_connect(btn,"clicked",G_CALLBACK(click_c),NULL);
  //显示窗体,
  gtk_widget_show (win);
}
  
  //程序入口
int main (int argc, char **argv) {
  GtkApplication *app;
  int stat;

  app = gtk_application_new ("com.github.ToshioCP.pr2", G_APPLICATION_FLAGS_NONE);
  g_signal_connect (app, "activate", G_CALLBACK (app_activate), NULL);
  stat =g_application_run (G_APPLICATION (app), argc, argv);
  g_object_unref (app);
  return stat;
}
